package com.enjoyor.soa.traffic.server.tsms.dubbo.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.enjoyor.soa.traffic.api.dto.tsms.AssessItemsScoreDto;
import com.enjoyor.soa.traffic.api.dto.tsms.PoliceAssessDto;
import com.enjoyor.soa.traffic.api.service.dubbo.tsms.IDubboPoliceAssessService;
import com.enjoyor.soa.traffic.core.tsms.domain.AssessItemsScore;
import com.enjoyor.soa.traffic.core.tsms.domain.PoliceAssess;
import com.enjoyor.soa.traffic.core.tsms.service.IPoliceAssessService;
import com.enjoyor.soa.traffic.frame.support.util.DomainUtil;
import com.enjoyor.soa.traffic.util.helper.ReflectHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@SuppressWarnings("rawtypes")
@Service(version = "1.0.0", timeout = 4000)
public class DubboPoliceAssessService implements IDubboPoliceAssessService{

	@Autowired
	private IPoliceAssessService iPoliceAssessService;
	
	@Override
	public ResultPojo getPoliceAssessPage(Page page, String assessId, String executeTaskId, String policeId) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo(iPoliceAssessService.getPoliceAssessPage(page, assessId, executeTaskId, policeId));
		return resultPojo;
	}

	@Override
	public ResultPojo getPoliceAssessList(String assessId, String executeTaskId, String policeId) {
		// TODO Auto-generated method stub
		List<PoliceAssess> list = iPoliceAssessService.getPoliceAssessList(assessId, executeTaskId, policeId);
		ResultPojo resultPojo = new ResultPojo(ReflectHelper.listToList(list, PoliceAssessDto.class));
		return resultPojo;
	}

	@Override
	public ResultPojo insertPoliceAssess(PoliceAssessDto policeAssessDto, String personName) {
		// TODO Auto-generated method stub
		iPoliceAssessService.addPoliceAssess(ReflectHelper.beanToBean(policeAssessDto, PoliceAssess.class),personName);
		return new ResultPojo();
	}

	@Override
	public ResultPojo editPoliceAssess(PoliceAssessDto policeAssessDto, String personName) {
		// TODO Auto-generated method stub
		iPoliceAssessService.editPoliceAssess(ReflectHelper.beanToBean(policeAssessDto, PoliceAssess.class),personName);
		return new ResultPojo();
	}

	@Override
	public ResultPojo deletePoliceAssess(String assessId, String executeTaskId, String policeId, String personName) {
		// TODO Auto-generated method stub
		iPoliceAssessService.deletePoliceAssess(assessId, executeTaskId, policeId, personName);
		return new ResultPojo();
	}

	@Override
	public ResultPojo assessPoliceScore(PoliceAssessDto policeAssessDto, List<AssessItemsScoreDto> list,
			String personName) {
		// TODO Auto-generated method stub
		List<AssessItemsScore> listAssessItemsScore = DomainUtil.merge2ListJson(list, AssessItemsScore.class);
		PoliceAssess policeAssess = ReflectHelper.beanToBean(policeAssessDto, PoliceAssess.class);
		iPoliceAssessService.assessPoliceScore(policeAssess, listAssessItemsScore, personName);
		return new ResultPojo();
	}

}
